import { modal, clearStorage, getStorage } from "../../utils/storage"
Page({
  data: {
    roleNames: [],
    user: {
      userAccount: '',
      userName: "",
      collegeCode: '',
      collegeName: ""
    },
  },
  onLoad() {
    let data = getStorage(wx.$USER_NAME);
    if (!data) {
      wx.redirectTo({
        url: '/pages/index/index',
      });
      return;
    }
    let roleNames = data.sysRoleVOList.map(x => x.roleName);
    this.setData({
      roleNames,
      user: data
    })
  },
  async logout() {
    let config = await modal({ content: '确定退出素质素养平台？' });
    if (config) {
      clearStorage(wx.$TOKEN_NAME);
      wx.redirectTo({
        url: '/pages/index/index',
      })
    }
  },
  onShareAppMessage(){
    return getApp().globalData.shareApp;
  }
})